<?php
include("../../share/config.php");

$building = $_POST["building"];
$id = $_POST["cr_no"];
$type = $_POST["type"];
$many = $_POST["many"];

$sql="SELECT * from cr_info where cr_no = '$id' AND building = '$building'";
$search = mysqli_query($conn,$sql);
$count=mysqli_num_rows($search);
if ($count>0)
{
	echo "<a href='../../pages/admin/signup.php'>此教室已被注册，如有问题请咨询管理员！</a>";
}
else
{
		$sql = "INSERT INTO `Lib`.`cr_info`(building,cr_no,cr_type,cr_max) VALUES('{$building}','{$id}','{$type}','{$many}')";
		$insert = mysqli_query($conn,$sql);  
		mysqli_close($conn);
		Header("Location:../../pages/admin/newcr.php");
}

?>
 